import rospy
import cv2
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
import sys

save_path = sys.argv[1]

rospy.init_node('image_saver')
bridge = CvBridge()
def image_callback(image_data):
    cv_image = bridge.imgmsg_to_cv2(image_data, desired_encoding='passthrough')
    cv2.imwrite(save_path, cv_image)
    sys.exit()

rospy.Subscriber('/image/front_mid', Image, image_callback)

rospy.spin()
